from appium import webdriver
from pages.main_page import MainPage
import logging


class App:

    def start_app(self):
        desire_caps = {
            "platformName": "android",
            "appPackage": "com.tencent.wework",
            "appActivity": ".launch.WwMainActivity",
            "noReset": True,
            "skipDeviceInitialization": True,
            "unicodeKeyBoard": True
        }
        logging.info("启动APP: "+str(desire_caps))
        self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desire_caps)
        self.driver.implicitly_wait(5)

        return self

    def stop_app(self):
        logging.info("关闭APP")
        self.driver.quit()

    def go_to_main(self):
        logging.info("打开主页面")
        return MainPage(self.driver)